package com.lh.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.lh.dto.AgeDto;
import com.lh.dto.IdDto;
import com.lh.dto.NameDto;
import com.lh.service.DemoService;

import java.util.ArrayList;
import java.util.List;

// provider 实现公共接口，此实现对消费者隐藏：
@Service(version = "1.0.0", timeout = 10000, interfaceClass = DemoService.class)
//@Service
public class DemoServiceImpl implements DemoService {

    @Override
    public AgeDto age(AgeDto dto) {
        System.out.println("接收到dto id ：" + dto.getId());
        System.out.println("接收到dto age ：" + dto.getAge());
        return AgeDto.id(99L).age(99L);
    }

    @Override
    public NameDto name(NameDto dto) {
        System.out.println("接收到dto id ：" + dto.getId());
        System.out.println("接收到dto name ：" + dto.getName());
        NameDto nameDto = new NameDto();
        nameDto.setId(99L);
        nameDto.setName("lily");
        return nameDto;
    }

    @Override
    public IdDto dto(IdDto dto) {
        System.out.println("接收到dto：" + dto.toString());
        return IdDto.builder(99L);
    }

    @Override
    public String hello(String string) {
        return "我是服务提供者，你好呀 你传递的信息是 " + string;
    }

    @Override
    public List<String> getPermissions(Long id) {
        List<String> demo = new ArrayList<String>();
        demo.add(String.format("Permission_%d", id - 1));
        demo.add(String.format("Permission_%d", id));
        demo.add(String.format("Permission_%d", id + 1));
        return demo;
    }

}
